//@author A0081229H
package storage;

import java.io.PrintWriter;

public class Helper {
	public static final int MORE = 1;
	public static final int SAME = 0;
	public static final int LESS = -1;
	public static final String ZERO = "0";
	public static final String SPACE = " ";
	public static final String ERROR_NULL = "Parameter(s) cannot be null.";

	public static Integer compareNullCheck(Integer argHome, Integer argOther) {
		if (argHome == null && 
				argOther == null) {
			return SAME;
		} else if (argOther == null) {
			return MORE;
		} else if (argHome == null) {
			return LESS;
		} else {
			return null;
		}
	}

	public static int compareToAbstract(Integer argHome, Integer argOther, int argElse) {
		Integer comparatorCounter = Helper.compareNullCheck(argHome, argOther);
		if (comparatorCounter != null) {
			return comparatorCounter;
		}
		if (argHome > argOther) {
			return MORE;
		} else if (argHome < argOther) {
			return LESS;
		} else {
			return argElse;
		}
	}

	public static int compareToCustom(Integer homeFirst, Integer otherFirst, 
			Integer homeSecond, Integer otherSecond, 
			Integer homeThird, Integer otherThird) {
		return compareToAbstract(homeFirst, otherFirst,
				compareToAbstract(homeSecond, otherSecond,
						compareToAbstract(homeThird, otherThird, SAME)));
	}

	public static int compareSameStyle(int argOne, int argTwo) {
		if (argOne == Helper.SAME) {
			return argTwo;
		} else {
			return argOne;
		}
	}

	public static void processZero(PrintWriter pw, Integer i) {
		if (i < 10) {
			pw.write(ZERO);
		}
	}

	public static void writeIntToStr(Integer i, PrintWriter pw) {
		pw.write(i.toString());
	}	
}
